import {types} from '.';
import {fromJS} from "immutable";

/**
 * DEFAULT REDUCER
 */
const defaultData = fromJS({
    /** 关于用户列表 **/
    // 全部用户数据（当前页的数据）
    UserList: [],
    // 当前Page页数
    UserCurrentPage: 1,
    // 总共Page页数
    UserTotalPage: 1,
    // 一个Page页内展示的用户信息数量
    UserListPageSize: 10,
    // 总计用户数
    UserCounts: 0


})

const admin = (state = defaultData, {type, value}) => {
    if (value !== undefined && value !== null) {
        switch (type) {
            case types.ADMIN_INIT_TOTAL_USER:
                return state.set('UserList', value);
            case types.ADMIN_USER_INFO_CURRENT_PAGE:
                return state.set('UserCurrentPage', value);
            case types.ADMIN_USER_INFO_TOTAL_PAGE:
                return state.set('UserTotalPage', value);
            case types.ADMIN_USER_INFO_PAGE_SIZE:
                return state.set('UserListPageSize', value);
            case types.VALUE_IS_OBJECT:
                return state.merge(value);
            default:
                return state;
        }
    }
    return state;
}
export default admin;
